home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / gjr / cmplrtst.lha / vector.scm < prev    next >
Encoding:
Text File  |  1990-03-27  |  346 b   |  20 lines

  1. ;;; -*- Scheme -*-
  2.  
  3. #|
  4. Description:
  5. This code tests vector indexing and some arithmetic
  6.  
  7. Usage:
  8. (odd-elements '#(8 7 6 5 4 3 2 1)) -> (8 6 4 2)
  9. |#
  10.  
  11. (declare (usual-integrations))
  12.  
  13. (define (odd-elements v)
  14.   (let ((l (vector-length v)))
  15.     (define (do-it n)
  16.       (if (>= n l)
  17.       '()
  18.       (cons (vector-ref v n)
  19.         (do-it (+ n 2)))))
  20.     (do-it 0)))